
import java.io.*;
import java.util.Hashtable;
import java.util.Scanner;
import java.util.StringTokenizer;
//import java.util.Enumeration;

 
// Rtype Instructions include :
   // add,sub
// Itype Instructions include :
  // load,store,bez,addi
// add 	 rd, rs, rt 	 100000 
// sub 	 rd, rs, rt 	 100010 
// load r1, 0(r2)        100011
// store r1, 0(r2)       100100
// bez r1, done          100110 branch if register is equal to zero       
// addi r1, r0, imm      100111  


public class test5 {

	//static String[] rtype ={"add","sub"};
	//static String[] itype ={"load","store","bez","addi"};
    @SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {
        Scanner s = null;
        int m;
        int i = 0;
        String[] strlines = new String[100]; // Considering the string to be less than 100 lines
        String[] hash1 = new String[50];
     // Forming the Key Value pairs by using a Hasp-map, we can also use a Hash-table here!!	  
  	  Hashtable<String, String> ht = new Hashtable<String,String>();
  	  
      // forming the Key value pairs for the Instructions both R-type and I-type
      
      ht.put("add","100000");
      ht.put("sub","100010");
      ht.put("load","100011");
      ht.put("Store","100100");
      ht.put("bez","100110");
      ht.put("addi","100111");
      // forming the key value pairs for the registers 
      
      ht.put("r0", "00000");
      ht.put("r1", "00001");
      ht.put("r2", "00010");
      ht.put("r3", "00011");
      ht.put("r4", "00100");
      ht.put("r5", "00101");
      ht.put("r6", "00110");
      ht.put("r7", "00111");
      ht.put("r8", "01000");
      ht.put("r9", "01001");
      ht.put("r10", "01010");
      ht.put("r11", "01011");
      ht.put("r12", "01100");
      ht.put("r13", "01101");
      ht.put("r14", "01110");
      ht.put("r15", "01111");
      ht.put("r16", "10000");
      ht.put("r17", "10001");
      ht.put("r18", "10010");
      ht.put("r19", "10011");
      ht.put("r20", "10100");
      ht.put("r21", "10101");
      ht.put("r22", "10110");
      ht.put("r23", "10111");
      ht.put("r24", "11000");
      ht.put("r25", "11001");
      ht.put("r26", "11010");
      ht.put("r27", "11011");
      ht.put("r28", "11100");
      ht.put("r29", "11101");
      ht.put("r30", "11110");
      ht.put("r31", "11111");
        //Scanner s1 = null;
      //Path file = "C:\\Users\\User\\Desktop\\CA\\example.txt";
      //InputStream in = null;
      BufferedReader obj = null ;
      try {
          //in = file.newInputStream();
          obj = new BufferedReader(new FileReader("C:\\Users\\User\\Desktop\\CA\\example.txt"));
          String line = null;
          
          
          while ((line = obj.readLine()) != null) {
        	  i++;
        	    String str2;
        	    //String str1 = i;
        	    //System.out.println("Enter Second String:");
        	    String str1 = line;
        	    //System.out.println("Combin string example!");
        	    str2 = i + " " + str1;
        	    strlines[i] = str2; 
         	    
          }
      } catch (IOException x) {
          System.err.println(x);
      } finally {
          if (obj != null) {
              obj.close();
          }
      }
      for (int n = 1; n<i ; n++) {
    	//System.out.println(strlines[n]);
      s = new Scanner(strlines[n]);
      s.useDelimiter(", *");
      
      while (s.hasNext()) {
          //System.out.println(s.next());
      	 //i++;
      	 String str1 ;
      	 str1 = s.next();
      	 //s1 = new Scanner(new BufferedReader(new FileReader("str1")));
      	 StringTokenizer st = new StringTokenizer(str1);
      	 m = st.countTokens();
      	 System.out.println(m);
           while (st.hasMoreTokens()) {
        	   if(st.countTokens() != m)
        	   {
        		   
        	   }
        	    //m =  st.countTokens();
        	    //System.out.println(m);
               //System.out.println(st.nextToken());
               //System.out.println("Remaining Tokens : " + st.countTokens());
               //System.out.println(st.nextToken());
        	    
           }
            
      }
               //String str2 ;
              // str2 = st.nextToken();  
    }
}
    
}    

